package single;

import consumer.Consumer;
import producer.Producer;
import queue.Queue1;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author Xu,
 * @data 2020/12/19，
 * @time 16:52
 * 单线程下一个生产者与一个消费者，生成一百万个大于20亿的随机数，并判断他们是否素数；
 */
public class Single {
    public static void main(String[] args) throws InterruptedException {
        long start = System.currentTimeMillis();
        Queue1 queue = new Queue1();
        Producer producer = new Producer(queue,1000000);
        Thread t1 = new Thread(producer);
        Consumer consumer = new Consumer(queue, 1000000);
        Thread t2 = new Thread(consumer);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(producer.getCount());
        System.out.println(consumer.getCount());
        long end = System.currentTimeMillis();
        System.out.println("runtime: " + (end-start)/1000.0 + "s");
    }
}
